package com.example.ylgh.controller;

import com.example.result.Result;
import com.example.ylgh.model.hosp.Schedule;
import com.example.ylgh.service.ScheduleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author hx
 * @create 2022/5/16 11:05
 * description:
 */
@RestController
@RequestMapping("/admin/hosp/schedule")
//@CrossOrigin
public class ScheduleController {
    @Autowired
    private ScheduleService scheduleService;

    /**
     * 根据医院编号 和 科室编号，查询排版规则数据
     * @param depcode
     * @param hoscode
     * @param limit
     * @param page
     * @return
     */
    @GetMapping("/getScheduleRule/{page}/{limit}/{hoscode}/{depcode}")
    public Result getScheduleRule(@PathVariable String depcode,
                                  @PathVariable String hoscode,
                                  @PathVariable long limit,
                                  @PathVariable long page){
        Map<String, Object> map =scheduleService.getRuleSchedule(depcode,hoscode,limit,page);
        return Result.ok(map);
    }

    /**
     * 根据医院编号 科室编号和工作日期查询排版详细信息
     * @param depcode
     * @param hoscode
     * @param workDate
     * @return
     */
    @GetMapping("/getScheduleDetail/{hoscode}/{depcode}/{workDate}")
    public Result getScheduleDetail(@PathVariable String hoscode,
                                    @PathVariable String depcode,
                                    @PathVariable String workDate){
        List<Schedule> list =scheduleService.getScheduleDetail(hoscode,depcode,workDate);
        return Result.ok(list);
    }
}
